package com.sdx.console.content.entity;

import com.ibeetl.admin.core.entity.BaseEntity;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.sdx.common.utils.Utils;
import lombok.Data;
import org.beetl.sql.core.annotatoin.AutoID;
import org.beetl.sql.core.annotatoin.ColumnIgnore;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;


/*
*
* gen by Spring Boot2 Admin 2018-10-19
*/
@Data
public class ResContentMain extends BaseEntity{

    //内容id
    @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
    @AutoID
    private Integer contentId ;

    //媒介类型 1、视频；2、音频；3、文章

    private Integer mediaType ;

    //内容标题

    private String contentTitle ;

    //封面

    private String cover ;

    //免费章节数 最终按章节表是否免费判断

    private Integer freeChapters ;

    //客户ID
    private  String  customerId;

    //作者（老师）

    private String author ;

    //短介绍

    private String brief ;

    //详情介绍

    private String contentDesc ;

    //内容标签 空格隔开多个

    private String contentTags ;

    //章节数

    private Integer chapterNum ;

    //全部价格

    private BigDecimal price ;

    //单章价格

    private BigDecimal chapterPrice ;

    //订购人数

    private Integer orderCount ;

    //观看人数

    private Integer viewCount ;

    //可用标记 1、可用，0、不可用

    private Integer contentStatus ;

    //创建人

    private Integer createdBy ;

    //创建人名称

    private String createdName ;

    //创建时间

    private Date createdTime ;

    //更新人

    private Integer updatedBy ;

    //更新人名称

    private String updatedName ;

    //更新时间

    private Date updatedTime ;

    private Integer provinceId;
    private Integer orgId;
    private Integer freeFlag;
    private Integer isTop;

    private String contentType;

    private Integer moduleId;

    @ColumnIgnore
    private String provName;
	@ColumnIgnore
    private String moduleName;

	public String getCoverView(){
		return Utils.imageUrl(cover);
	}

	private Date startTime;

	private Date endTime;

    private String createdTimeQuery;

    /*
        是否推荐 0 否 1是
     */
    private Integer isRecommend;

    public void setCreatedTimeQuery(String createdTimeQuery) {
        this.createdTimeQuery = createdTimeQuery;
        Date[] timePair = Utils.parseQueryTime(createdTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.startTime = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.endTime = timePair[1];
        }
    }

}
